﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace wpf事件类型 {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }

        #region 键盘事件
        //private void TextBox_KeyEvent(object sender, KeyEventArgs e) {
        //    var message = $"Event:{e.RoutedEvent} Key:{e.Key}";
        //    this.FstMessage.Items.Add(message);
        //}

        //private void TextBox_TextEvent(object sender, TextCompositionEventArgs e) {
        //    var message = $"Event:{e.RoutedEvent} Key:{e.Text}";
        //    this.FstMessage.Items.Add(message);
        //}

        //private void TextBox_TextChanged(object sender, TextChangedEventArgs e) {
        //    var message = $"Event:{e.RoutedEvent}";
        //    this.FstMessage.Items.Add(message);
        //}

        //private void Button_Click(object sender, RoutedEventArgs e) {
        //    FstMessage.Items.Clear ();
        //}
        #endregion

        #region 鼠标点击和鼠标捕获
        //private void rect_MouseMove(Object sender, MouseEventArgs e) { 
        //    Point pt = e.GetPosition(this);
        //    lblInfo.Text = $"You are at X:{pt.X.ToString()}, Y:{pt.Y.ToString()} in {e.Source}";
        //}

        //private void cmdCapture_Click(object sender, RoutedEventArgs e) {
        //    Mouse.Capture(this.rect);
        //    this.cmdCapture.Content = "Mouse is now Captured";
        //}
        #endregion

        #region 鼠标拖放

        #endregion

        private void lblSource_MouseDown(object sender, MouseButtonEventArgs e) {
            Label lbl = sender as Label;
            DragDrop.DoDragDrop(lbl, lbl.Content, DragDropEffects.Copy);
        }

        private void lblTarget_Drop(object sender, DragEventArgs e) {
            ((Label)sender).Content = e.Data.GetData(DataFormats.Text);
        }
    }
}
